<template>
  <!-- 滑动菜单组件 -->
  <div class="Hellmenu">
    <van-swipe :show-indicators="false">
      <van-swipe-item v-for="(page, index) of pages" :key="index">
        <div class="menu" v-for="item of page" :key="item.id">
          <div class="menu-img">
            <img class="imgcontent" :src="item.img" alt="" />
          </div>
          <p class="menu-desc">{{ item.desc }}</p>
        </div>
      </van-swipe-item>
    </van-swipe>
  </div>
</template>
<script>
export default {
  name: "Hellmenu",
  data() {
    return {
      iconList: [
        { id: "001", img: require("../assets/img/piao.png"), desc: "欢迎来到" },
        { id: "002",img: require("../assets/img/piao.png"), desc: "喳喳琴年代"},
        { id: "003", img: require("../assets/img/piao.png"), desc: "有请主演" },
        { id: "004", img: require("../assets/img/train.png"), desc: "方景琴" },
        { id: "005", img: require("../assets/img/hotel.png"), desc: "来演绎" },
        { id: "006", img: require("../assets/img/page.png"), desc: "渣渣养成" },
        { id: "007", img: require("../assets/img/piao.png"), desc: "渣出人生" },
        { id: "008", img: require("../assets/img/piao.png"), desc: "入戏太深" },
        { id: "009", img: require("../assets/img/piao.png"), desc: "来日方长" },
        { id: "010", img: require("../assets/img/piao.png"), desc: "啥也不是" },
        { id: "011", img: require("../assets/img/piao.png"), desc: "怎么看都香"},
        { id: "012", img: require("../assets/img/piao.png"), desc: "真香警告" },
        { id: "013", img: require("../assets/img/piao.png"), desc: "越香月刊" },
        { id: "014", img: require("../assets/img/piao.png"), desc: "没事尬聊" },
      ],
    };
  },
  components: {},
  computed: {
    pages() {
      const pages = [];
      this.iconList.forEach((item, index) => {
        const page = Math.floor(index / 8);
        if (!pages[page]) {
          pages[page] = [];
        }
        pages[page].push(item);
      });
      return pages;
    },
  },
};
</script>
<style lang="less" scoped>
.Hellmenu {
  width: 100%;
  height: 0;
  overflow: hidden;
  margin-top: .1rem;
  padding-bottom: 50%;
  .menu {
    float: left;
    width: 25%;
    height: 0;
    overflow: hidden;
    padding-bottom: 25%;
    position: relative;
    .menu-img {
      top: 0;
      left: 0;
      right: 0;
      bottom: 0.44rem;
      padding: 0.1rem;
      position: absolute;
      .imgcontent {
        display: block;
        margin: 0 auto;
        height: 100%;
      }
    }
    .menu-desc {
      left: 0;
      right: 0;
      bottom: 0;
      color: #333;
      height: 0.44rem;
      text-align: center;
      line-height: 0.44rem;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      position: absolute;
    }
  }
}
</style>